package com.mdinfo.db.test.aopu;

import com.mdinfo.gw.door.doorDriver.aopu.request.*;
import com.mdinfo.gw.door.doorDriver.aopu.utils.AopuUtil;
import org.apache.commons.lang3.time.DateUtils;
import org.junit.Test;

import java.util.Date;

/**
 * Created by Administrator on 2018/2/5.
 */
public class AopuTest02 {

    /**
     * 新增门禁
     */
    @Test
    public void mjAdd(){
        String host = "172.16.15.203";
        Integer port = 8000;
        String mode = "aopu.menjin.5";
        Integer mjno = 1;
        MJAddReq req = new MJAddReq(mjno,host,port,mode);
        AopuUtil.send(req);
    }

    /**
     * 修改门禁
     */
    @Test
    public void mjModify(){
        String host = "172.16.15.203";
        Integer port = 8000;
        String mode = "aopu.menjin.5";
        Integer mjno = 1;
        MJModReq req = new MJModReq(mjno,host,port,mode);
        AopuUtil.send(req);
    }

    /**
     * 删除门禁
     */
    @Test
    public void mjDelete(){
        Integer mjno = 1;
        MJDelReq req = new MJDelReq(mjno);
        AopuUtil.send(req);
    }

    /**
     * 门禁重置
     */
    @Test
    public void mjReset(){
        Integer mjno = 1;
        MJResetReq req = new MJResetReq(mjno);
        AopuUtil.send(req);
    }

    /**
     * 门注册
     */
    @Test
    public void doorAdd(){
        Integer mjno = 1;
        Integer drno = 1;
        DoorAddReq req = new DoorAddReq(mjno,drno);
        AopuUtil.send(req);
    }

    /**
     * 修改门
     */
    @Test
    public void doorModify(){
        Integer mjno = 1;
        Integer drno = 1;
        DoorModReq req = new DoorModReq(mjno,drno);
        AopuUtil.send(req);
    }

    /**
     * 删除门
     */
    @Test
    public void doorDelete(){
        Integer mjno = 1;
        Integer drno = 1;
        DoorDelReq req = new DoorDelReq(mjno,drno);
        AopuUtil.send(req);
    }

    /**
     * 开门
     */
    @Test
    public void doorOpen(){
        Integer mjno = 1;
        Integer drno = 1;
        DoorOpenReq req = new DoorOpenReq(mjno,drno);
        AopuUtil.send(req);
    }

    /**
     * 关门
     */
    @Test
    public void doorclose(){
        Integer mjno = 1;
        Integer drno = 1;
        DoorCloseReq req = new DoorCloseReq(mjno,drno);
        AopuUtil.send(req);
    }

    /**
     * 清除门开放时间
     */
    @Test
    public void doorDeleteTime(){
        Integer mjno = 1;
        Integer drno = 1;
        DoorDelTimeReq req = new DoorDelTimeReq(mjno,drno);
        AopuUtil.send(req);
    }

    /**
     * 设置门参数
     */
    @Test
    public void doorSetParam(){
        Integer mjno = 1;
        Integer drno = 1;
        Integer opDrTime = 20;
        Integer overTime = 10;
        DoorSetParamReq req = new DoorSetParamReq(mjno,drno,opDrTime,overTime);
        AopuUtil.send(req);
    }

    /**
     * 增加一个开放时间
     */
    @Test
    public void OpenTimeAdd(){
        Integer mjno = 1;
        String startTime = "00:00:00";
        String endTime = "23:59:59";
        String week = "1,2,3,4,5,6,7";
        int mode = 1;
        Date endDate = DateUtils.addYears(new Date(),5);
        OpenTimeAddReq req = new OpenTimeAddReq(mjno,startTime,endTime,week,mode,endDate);
        AopuUtil.send(req);
    }

    /**
     * 清除所有卡
     */
    @Test
    public void cardDeleteAll(){
        Integer mjno = 1;
        CardDelAllReq req = new CardDelAllReq(mjno);
        AopuUtil.send(req);
    }

    /**
     * 单门增加卡
     */
    @Test
    public void cardAdd(){
        Integer mjno = 1;
        Integer drno = 1;
        String cardno = "1234567";
        String passwd = "123";
        String openTime = "0000000000000001";
        String period = "180205";
        Integer status = 1;
        CardAddReq req = new CardAddReq(mjno,drno,cardno,passwd,openTime,period,status);
        AopuUtil.send(req);
    }

    /**
     * 事件上报
     */
    @Test
    public void eventUpload(){
        Integer mjno = 1;
        Integer drno = 1;
        String cardno = "1234567";
        String time = "180205181655";
        Integer type = 10;
        Integer otherRecord = 1;
        Integer eventTrace = 88;
        EventReq req = new EventReq(mjno,drno,cardno,time,type,otherRecord,eventTrace);
        AopuUtil.send(req);
    }
}
